package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysOutletInventory;
import com.ruoyi.system.service.ISysOutletInventoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 网点库存Controller
 * 
 * @author ruoyi
 * @date 2024-07-23
 */
@RestController
@RequestMapping("/system/inventory")
public class SysOutletInventoryController extends BaseController
{
    @Autowired
    private ISysOutletInventoryService sysOutletInventoryService;

    /**
     * 查询网点库存列表
     */
    @PreAuthorize("@ss.hasPermi('system:inventory:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysOutletInventory sysOutletInventory)
    {
        startPage();
        List<SysOutletInventory> list = sysOutletInventoryService.selectSysOutletInventoryList(sysOutletInventory);
        return getDataTable(list);
    }

    /**
     * 导出网点库存列表
     */
    @PreAuthorize("@ss.hasPermi('system:inventory:export')")
    @Log(title = "网点库存", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysOutletInventory sysOutletInventory)
    {
        List<SysOutletInventory> list = sysOutletInventoryService.selectSysOutletInventoryList(sysOutletInventory);
        ExcelUtil<SysOutletInventory> util = new ExcelUtil<SysOutletInventory>(SysOutletInventory.class);
        util.exportExcel(response, list, "网点库存数据");
    }

    /**
     * 获取网点库存详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:inventory:query')")
    @GetMapping(value = "/{oId}")
    public AjaxResult getInfo(@PathVariable("oId") Long oId)
    {
        return success(sysOutletInventoryService.selectSysOutletInventoryByOId(oId));
    }

    /**
     * 新增网点库存
     */
    @PreAuthorize("@ss.hasPermi('system:inventory:add')")
    @Log(title = "网点库存", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysOutletInventory sysOutletInventory)
    {
        return toAjax(sysOutletInventoryService.insertSysOutletInventory(sysOutletInventory));
    }

    /**
     * 修改网点库存
     */
    @PreAuthorize("@ss.hasPermi('system:inventory:edit')")
    @Log(title = "网点库存", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysOutletInventory sysOutletInventory)
    {
        return toAjax(sysOutletInventoryService.updateSysOutletInventory(sysOutletInventory));
    }

    /**
     * 删除网点库存
     */
    @PreAuthorize("@ss.hasPermi('system:inventory:remove')")
    @Log(title = "网点库存", businessType = BusinessType.DELETE)
	@DeleteMapping("/{oIds}")
    public AjaxResult remove(@PathVariable Long[] oIds)
    {
        return toAjax(sysOutletInventoryService.deleteSysOutletInventoryByOIds(oIds));
    }
}
